package gvo.search;

public class ListEntry {
	public int idBuch;
	public String value;
	public static final String XMLNAME = "ListEntry";
	public static final String[] Titel = { "idBuch", "value" };
	public static final int IDBUCH = 0;
	public static final int VALUE = 1;

	public ListEntry(int idBuch, String value) {
		this.idBuch = idBuch;
		this.value = value;
	}

	public String info() {
		return String.format("LISTENTRY %5d | %10.10s ", idBuch, value);
	}

	public static String infoTitel() {
		return String.format("LISTENTRY %5.5s | %10.10s ", (Object[]) Titel);
	}
	public String infoCSV() {
		return String.format("%d\t%s", idBuch, value);
	}

	public static String infoTitelCSV() {
		return String.format("%s\t%s", (Object[]) Titel);
	}
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof ListEntry)) {
			return false;
		}
		ListEntry other = (ListEntry) object;
		if ((this.idBuch == other.idBuch) && (this.value.equals(other.value))) {
			return true;
		}
		return false;

	}
	@Override
	public int hashCode() {
		int hash = 7;
		hash = 31 * hash + idBuch;
		hash = 31 * hash + (null == value ? 0 : value.hashCode());
		return hash;
	}

	public String toString() {
		if(value==null || value.equals("")){
			return "<leer>";
		}
		return value;
	}
}
